import {Injectable} from '@angular/core';
import {adSystemApiUrl, tuikeSystemUrl} from "../../../config/api";
import {Headers, RequestOptions} from "@angular/http";
import {HttpService} from "../../lib/service/http.service";

@Injectable()
export class CategoryService {

  constructor(private httpService: HttpService) {
  }


  // 类目
  delCategory(id: number) {
    const url = `${tuikeSystemUrl}/api/v1/admin/category/delete_category`;
    const headers = new Headers({'Content-Type': 'application/json'});
    const options = new RequestOptions({headers: headers});
    const body = JSON.stringify({id: id});
    return this.httpService.httpPostAuth(url, body, options).map(rs => rs);
  }

  getCategoryList(level, parent) {
    const url = `${tuikeSystemUrl}/api/v1/admin/category/category_list?level=${level}&parent_id=${parent}&pageSize=200`;
    return this.httpService.httpGetAuth(url).map(res => res);
  }
}
